<?php

namespace polymerize\user\module\user;


use app\common\InstanceTrait;
use app\model\User as UserModel;

class GetUserInfo
{
    use InstanceTrait;

    /**
     * 用户信息
     *
     * @param int $uid
     * @return array
     */
    public function getUserInfo(int $uid): array
    {
        $data = ['user_info' => null, 'vip_info' => null];
        if (!$uid) return $data;

        $userInfo = UserModel::getOne(['id' => $uid], '*');

        if ($userInfo) {
            if (isset($user_info['avatar']) && $userInfo['avatar'] && !strstr($userInfo['avatar'], 'http')) {
                $userInfo['avatar'] = OSS_URL . $userInfo['avatar'];
            }
            $userInfo['birthday'] = (isset($user_info['birthday']) && $user_info['birthday']) ? $userInfo['birthday'] : '';

            //手机号加密
            $userInfo['mobile'] = UserModel::getField(['id' => $uid], 'mobile');
//            $userInfo['mobile_aes'] = $userMobile ? AesService::instance()->setkey(API_AES_KEY)->encrypt($userMobile) : '';
        }

        return $userInfo;
    }
}
